// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   PRNG.java

package gnu.crypto.util;

import gnu.crypto.Properties;
import gnu.crypto.prng.*;
import java.util.HashMap;

public class PRNG
{

    private PRNG()
    {
    }

    public static void nextBytes(byte buffer[])
    {
        nextBytes(buffer, 0, buffer.length);
    }

    public static void nextBytes(byte buffer[], int offset, int length)
    {
        try
        {
            singleton.nextBytes(buffer, offset, length);
        }
        catch(LimitReachedException x)
        {
            try
            {
                HashMap map = new HashMap();
                if(!Properties.isReproducible())
                {
                    long t = System.currentTimeMillis();
                    byte seed[] = {
                        (byte)(int)(t >>> 56), (byte)(int)(t >>> 48), (byte)(int)(t >>> 40), (byte)(int)(t >>> 32), (byte)(int)(t >>> 24), (byte)(int)(t >>> 16), (byte)(int)(t >>> 8), (byte)(int)t
                    };
                    map.put("gnu.crypto.prng.md.seed", seed);
                }
                singleton.init(map);
                singleton.nextBytes(buffer, offset, length);
            }
            catch(Exception y)
            {
                throw new ExceptionInInitializerError(y);
            }
        }
    }

    private static final IRandom singleton;

    static 
    {
        singleton = new MDGenerator();
        try
        {
            HashMap map = new HashMap();
            if(!Properties.isReproducible())
            {
                long t = System.currentTimeMillis();
                byte seed[] = {
                    (byte)(int)(t >>> 56), (byte)(int)(t >>> 48), (byte)(int)(t >>> 40), (byte)(int)(t >>> 32), (byte)(int)(t >>> 24), (byte)(int)(t >>> 16), (byte)(int)(t >>> 8), (byte)(int)t
                };
                map.put("gnu.crypto.prng.md.seed", seed);
            }
            singleton.init(map);
        }
        catch(Exception x)
        {
            throw new ExceptionInInitializerError(x);
        }
    }
}
